<?php


function dump($array)
{

  echo '<pre id="json-renderer"></pre>
<script src="/static/jquery/jquery-3.3.1.min.js"></script>
<script src="/static/json-viewer/jquery.json-viewer.js"></script>
<link href="/static/json-viewer/jquery.json-viewer.css" rel="stylesheet">

<script>
  var jsonData = ' . json_encode($array) . ';
  $(\'#json-renderer\').jsonViewer(jsonData);
</script>';
}


/**
 * 是否是json
 * @param mixed $string
 * @return bool
 */
function is_json($string)
{
  json_decode($string);
  return (json_last_error() == JSON_ERROR_NONE);
}

/**
 * win与linux路径转换
 * @param string $path
 * @return string
 */
function pathConvert(string $path): string
{
  if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
    return str_replace('/', '\\', $path);
  }
  return str_replace('\\', '/', $path);
}
